Package Question2_3

Source Code of Question2_3.Question

package Question2_3;

import CtCILibrary.AssortedMethods;
import CtCILibrary.LinkedListNode;

public class Question {

  public static boolean deleteNode(LinkedListNode n) {
    if (n == null || n.next == null) {
      return false; // Failure
    }
    LinkedListNode next = n.next;
    n.data = next.data;
    n.next = next.next;
    return true;
  }
 
  public static void main(String[] args) {
    LinkedListNode head = AssortedMethods.randomLinkedList(10, 0, 10);
    System.out.println(head.printForward());
    deleteNode(head.next.next.next.next); // delete node 4
    System.out.println(head.printForward());
  }

}
TOP

Related Classes of Question2_3.Question

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.